//
//  ZYCAttendanceStatisiticModel.m
//  ZDSC
//
//  Created by ZDTX on 2021/8/11.
//

#import "ZYCAttendanceStatisiticModel.h"

@interface ZYCAttendanceStatisiticModel ()
@property (nonatomic, strong) NSDateFormatter *dateFormatter;
@end
@implementation ZYCAttendanceStatisiticModel


- (NSString *)weekDay{
    NSDate *date = [self.dateFormatter dateFromString:self.currentDate];
    NSString *weekStr = [self weekdayStringWithDate:date];
    return weekStr;
}
- (NSString *)weekdayStringWithDate:(NSDate *)date {
    //获取星期几
    NSDateComponents *componets = [[NSCalendar autoupdatingCurrentCalendar] components:NSCalendarUnitWeekday fromDate:date];
    NSInteger weekday = [componets weekday];//1代表星期日，2代表星期一，后面依次
    NSArray *weekArray = @[@"星期日",@"星期一",@"星期二",@"星期三",@"星期四",@"星期五",@"星期六"];
    NSString *weekStr = weekArray[weekday-1];
    return weekStr;
}


- (NSDateFormatter *)dateFormatter {
    if (!_dateFormatter) {
        _dateFormatter = [[NSDateFormatter alloc] init];
        _dateFormatter.dateFormat = @"yyyy-MM-dd";
    }
    return _dateFormatter;
}
@end
